<template>
<div class="IconsBox">
  <swiper>
    <swiper-slide v-for="(page, index) of pages" :key="index">
      <div class="Icon fl" v-for="item of page" :key="item.id">
        <div class="IconImg">
          <img :src="item.path"
            alt=""
            class="IconImgContent"
      >
    </div>
    <p class="IconText text-wrap">{{item.text}}</p>
  </div>
    </swiper-slide>
  </swiper>
</div>
</template>
<script>
export default {
  name: 'HomeIcon',
  data () {
    return {
      IconList: [
        {
          id: '1',
          path: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          text: '景点'
        },
        {
          id: '2',
          path: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          text: '景点'
        },
        {
          id: '3',
          path: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          text: '景点'
        },
        {
          id: '4',
          path: 'http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png',
          text: '景点'
        }
      ]
    }
  },
  computed: {
    pages () {
      const pages = []
      this.IconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>
<style lang="scss" scoped>
@import '~style/base.scss';
.IconsBox >>> .swiper-container {
  overflow: hidden;
  height: 0;
  padding: {
    bottom: 50%;
  }
}
.IconsBox {
height: 0;
width: 100%;
color: $darkText;
overflow: hidden;
text-align: center;
padding: {
  bottom: 50%;
}
.Icon {
 height: 0;
 width: 25%;
 padding: {
  bottom: 25%;
}
 overflow: hidden;
 position: relative;
 .IconImg {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: .22rem;
  box-sizing: border-box;
  padding: .05rem;
   .IconImgContent {
     display: block;
     margin: 0 auto;
     height: 100%;
   }
}
  .IconText {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: .22rem;
    line-height: .22rem;
    font-size: .13rem;
  }
}
}
</style>
